import { screen, keyboard, Key, sleep } from '@nut-tree/nut-js';
import '@nut-tree/template-matcher';
import addFriend from './addFriend.js';
import sendMessage from './sendMessage.js';
import createGroup from './createGroup.js';
import selectMessage from './selectMessage.js';

// Templates
screen.config.resourceDirectory = './src/wechat/templates';
screen.config.autoHighlight = true;
screen.config.highlightDurationMs = 1000;

// 打开企业微信（快捷键）：打开/隐藏主面板 Shift + Alt + S
await keyboard.pressKey(Key.LeftShift, Key.LeftAlt, Key.S);
await keyboard.releaseKey(Key.LeftShift, Key.LeftAlt, Key.S);

// 打开企业微信（快捷键）：打开/隐藏主面板 Shift + Cmd + W
// await keyboard.pressKey(Key.LeftShift, Key.LeftCmd, Key.W);
// await keyboard.releaseKey(Key.LeftShift, Key.LeftCmd, Key.W);
await sleep(2000);

// 1、添加好友
for(let i = 0; i < 100; i++) {
    console.log(`第${i + 1}次添加好友`);
    await addFriend();
}
// await addFriend();

// 2、向指定联系人发送消息
// for(let i = 0; i < 100; i++) {
//     console.log(`第${i + 1}次发送消息`);
//     await sendMessage(`第${i + 1}条消息`);
// }
// await sendMessage();

// 3、创建群聊
// await createGroup();

// 4、选择消息
// await selectMessage();